import 'package:flutter/material.dart';

class SliverContainerWidget extends SliverPersistentHeaderDelegate {
  late Widget child;
  late double height;

  SliverContainerWidget({
    required child,
    required height,
  }) {
    this.child = child;
    this.height = height;
  }

  @override
  Widget build(
    BuildContext context,
    double shrinkOffset,
    bool overlapsContent,
  ) {
    return Container(
      child: this.child,
      height: this.height,
    );
  }

  @override
  double get maxExtent => this.height;

  @override
  double get minExtent => this.height;

  @override
  bool shouldRebuild(covariant SliverContainerWidget oldDelegate) {
    return this.height != oldDelegate.height || child != oldDelegate.child;
  }
}
